<template>
    <XPTable ref='tableRef' :search='false' :api='pageApi' :columns='columns'>
        <template #time_spent='{record}'>{{record.time_spent}}秒</template>
        <template #status='{record}'>
            <XBackTestStatus :status='record.status' />
        </template>
    </XPTable>
</template>

<script lang='ts' setup>
    import { reactive, ref } from 'vue'
    import { strategyBackTestPageApi } from '@/api/strategy'
    import { Column } from '../../../../types'

    const props = defineProps<{
        id : number
    }>()

    async function pageApi(params:any) {
        return strategyBackTestPageApi({...params, strategy_id : props.id})
    }

    const columns = reactive<Column[]>([
        {title : '名称', dataIndex : 'strategy_name', align : 'center'},
        {title : '创建时间', dataIndex : 'create_at', align : 'center'},
        {title : '耗时', dataIndex : 'time_spent', align : 'center'},
        {title : '策略收益', dataIndex : 'strategy_return', align : 'center'},
        {title : '基准收益', dataIndex : 'benchmark_return', align : 'center'},
        {title : '最大回撤', dataIndex : 'max_drawdown', align : 'center'},
        {title : '状态', dataIndex : 'status', align : 'center'},
    ])
</script>
